﻿
var gPageIndex = 1;
var cateID = 100;
var learnLan = "";
var baseLan = "";
var active = false;
//搜索
function Browse()
{
    cateID = $get("SelectCat").value;
    learnLan=$get("SelectLearn").value;
    baseLan=$get("SelectBase").value;    
    if($get("RInactive").checked)
    {
        active = false;
    }
    else if($get("RActive").checked)
    {
        active = true;
    }
    WebServices.WWW.Resources.GetResourcesList(learnLan,baseLan,cateID,active,1,20,onsuccResource);    
}
//第一次
function onsuccResource(result)
{
    if(result[0].RecordCount==0)
    {
        $get("ResList").style.display='none';
        $get("NoResource").style.display='';
    }
    else
    {
        $get("ResList").style.display='';
        $get("NoResource").style.display='none';
        RendPageNavigator(result[0],"divPage","GetPageRes");
        RendResourceList(result[1],"ResList");
    }
}
//页
function GetPageRes(pageIndex)
{
		showProgressBar(true);
    gPageIndex=pageIndex;
    InitDataRes(pageIndex);   
}
//分页数据
function InitDataRes()
{
    WebServices.WWW.Resources.GetResourcesList(learnLan,baseLan,cateID,active,gPageIndex,20,onsuccRes);
}
//分页后的
function onsuccRes(result)
{
    RendPageNavigator(result[0],"divPage","GetPageRes");
    RendResourceList(result[1],"ResList");
    showProgressBar(false);
}
function RendResourceList(list,divID)
{
    var domDiv =$get(divID);    
    if(domDiv!=null)
    {  
        if(Sys.UI.DomElement.containsCssClass(domDiv, "DisplayNone"))
        {
            Sys.UI.DomElement.removeCssClass(domDiv, "DisplayNone");
        }
        var listBuilder = new Sys.StringBuilder();
        if($get("ResListItem")==null) return;                   
        var item= $get("ResListItem").innerHTML;
        for (var index = 0; index < list.length; index++) 
        {              
            var obj = list[index];
            var tmp = item.replace(/\$ResID\$/gi,obj.ResID).replace(/\$Name\$/gi,obj.Name).replace(/\$Url\$/gi,obj.Url).replace(/\$Description\$/gi,obj.Description);            
            listBuilder.append(tmp);
        }
        var sTemp = listBuilder.toString();
        domDiv.innerHTML = sTemp;
        
    }
}
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();

